Add tenancy access info to serialized user in threadcontext#63
Open
Add tenancy access info to serialized user in threadcontext#63
Conversation
Signed-off-by: Craig Perkins <cwperx@amazon.com>
Signed-off-by: Craig Perkins <cwperx@amazon.com>
nibix
reviewed
Jul 30, 2025
|
|
||
| String requestedTenant = context.getUser().getRequestedTenant(); | ||
| joiner.add(requestedTenant); | ||
| String tenantAccessToCheck = getTenancyAccess(requestedTenant, this.tenantPrivileges.get().tenantMap(context)); |
There was a problem hiding this comment.
For clusters with many tenants (I recently heard about one with 2000 tenants ;-) it will be significantly more efficient to use tenantPrivileges.hasTenantPrivilege():
tenantMap() needs to compute the privileges for all existing tenants and is therefore very slow
Owner
Author
There was a problem hiding this comment.
Does that distinguish between no access, read access and write access?
There was a problem hiding this comment.
well, we need to call it potentially twice:
- if (hasTenantPrivilege(ActionType.WRITE)) return "WRITE"
- else if (hasTenantPrivilege(ActionType.READ)) return "READ"
- else return "NONE"
Owner
Author
There was a problem hiding this comment.
got it, pushing a commit for that shortly.
Owner
Author
There was a problem hiding this comment.
Pushed a commit and opened a PR to the main repo: opensearch-project#5519
Signed-off-by: Craig Perkins <cwperx@amazon.com>
5 tasks
Signed-off-by: Craig Perkins <cwperx@amazon.com>
Signed-off-by: Craig Perkins <cwperx@amazon.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR adds information about the user's level of access to the requested tenant when serializing the user into the threadcontext. There can be 1 of 3 levels of access. 1) No Access - user has no access to the requested tenant, 2) Read Only - User has read only access to the requested tenant and 3) Write access - user can save saved objects to the requested tenant
Check List
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.